package cn.tedu.mapper;

import cn.tedu.pojo.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 使用注解方式进行开发,并且使用占位符传参
 */
@Mapper
public interface StudentMapper2 {
    //查询student表中的所有记录
    @Select("SELECT * FROM student")
    public List<Student> getStudentAll();

    //向student表中新增一条记录
    @Update("INSERT INTO student(id, name, age, gender, job, birth, location_id, team_leader, class_id)VALUES (null, #{name}, #{age}, #{gender}, #{job}, #{birth}, #{locationId}, #{teamLeader}, #{classId})")
    public int addStudent(Student student);

    //修改student表中的记录
    @Update("UPDATE student SET job = #{job} WHERE name = #{name}")
    public int updateStudent(String job, String name);

    //删除student表中的记录
    @Update("DELETE FROM student WHERE name = #{name}")
    public int deleteStudent(String name);
}
